package com.sgb.kjwl.view.widget;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.enterprise.ServiceQuoteEntity;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.util.DateUtils;


public class ServiceQuotePopWindow extends BasePopWindow {

    private ImageView ivCancel;
    Context context;

    ServiceQuoteEntity serviceQuoteEntity;
    TextView titleView;
    TextView price;
    TextView date;
    TextView enterprise;
    TextView detail;

    public ServiceQuotePopWindow(Context context) {
        super(context, DIR_DOWN_UP);
        this.context = context;
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_service_quote;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        holder.setBinding(BR.viewModel, serviceQuoteEntity);
        ivCancel = holder.getPop().findViewById(R.id.iv_cancel);
        ivCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        titleView = holder.getPop().findViewById(R.id.title_view);
        price = holder.getPop().findViewById(R.id.tv_price);
        date = holder.getPop().findViewById(R.id.tv_date);
        enterprise = holder.getPop().findViewById(R.id.tv_enterprise);
        detail = holder.getPop().findViewById(R.id.tv_detail);

    }


    public ServiceQuotePopWindow setData(ServiceQuoteEntity serviceQuoteEntity) {
        this.serviceQuoteEntity = serviceQuoteEntity;
        if (serviceQuoteEntity != null) {
            titleView.setText(serviceQuoteEntity.getName());
            price.setText("￥" + serviceQuoteEntity.getPrice());
            date.setText(DateUtils.timestampToDate(serviceQuoteEntity.getServiceTime()));
            enterprise.setText(serviceQuoteEntity.getCompanyName());
            detail.setText(serviceQuoteEntity.getProfile());
        }
        return this;
    }
}
